# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Tom Gundersen <teg@jklm.no>
# Contributor: AndyRTR <andyrtr@archlinux.org>
# Contributor: Lawrence Lee <valheru@facticius.net>

pkgname=rasqal
pkgver=0.9.33
pkgrel=6
epoch=1
pkgdesc="A library handling RDF query syntaxes, construction and execution"
license=(LGPL2.1)
url="https://librdf.org/rasqal"
arch=(loong64 x86_64)
depends=(
  glibc
  libgcrypt
  mpfr
  pcre
  sh
)
makedepends=(
  gtk-doc
  raptor
  util-linux
)
provides=(librasqal.so)
source=(https://download.librdf.org/source/$pkgname-$pkgver.tar.gz{,.asc})
sha512sums=('05728682797470db9e51d156012e8fde9dec1554d107372faa11cbe6cdc3356e92386f4f8de6d7c41e3100b76f9b1c6809102a913829cddbd2ff29043c04d522'
            'SKIP')
b2sums=('87bca86b2f0dceb0801f5a34dae9ae1f87d8a7d0dc1e03fdf04998a0d4885ed76be2719d3e01489a5510a26715bb093a75ce194cc42f3cedff88f64161d6a2fb'
        'SKIP')
validpgpkeys=('F879F0DEDA780198DD08DC6443EC92504F71955A') # Dave Beckett <dave@dajobe.org>

prepare() {
  cd $pkgname-$pkgver
  autoreconf -fiv
}

build() {
  local configure_options=(
    --prefix=/usr
    --disable-static
    --enable-release
  )

  cd $pkgname-$pkgver
  ./configure "${configure_options[@]}"
  # prevent excessive overlinking due to libtool
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  make -k check -C $pkgname-$pkgver
}

package() {
  depends+=(
    raptor libraptor2.so
    util-linux-libs libuuid.so
  )

  make DESTDIR="$pkgdir" install -C $pkgname-$pkgver
  install -vDm 644 $pkgname-$pkgver/{ChangeLog*,README,NEWS} -t "$pkgdir/usr/share/doc/$pkgname/"
}
